package com.base.system.managedBean.baseBean;

import java.io.Serializable;

import javax.faces.model.SelectItem;

import org.operamasks.faces.annotation.Accessible;
import org.operamasks.faces.annotation.Bind;
import org.operamasks.faces.annotation.SaveState;
import org.operamasks.faces.annotation.SelectItems;

import com.base.common.provider.SelectItemsProvider;
import com.base.commonKey.entity.CommonKeyType;
import com.base.commonKey.service.ICommonKeyService;
import com.base.commonKey.service.ICommonKeyTypeDao;
import com.base.commons.SpringBeanHolder;

public abstract class BaseCommonKeyTypeBean implements Serializable {
	@Bind(id = "id")
	private Integer id;

	@Bind(id = "typeCode")
	@SaveState
	private String typeCode;

	@Bind(id = "typeName")
	private String typeName;

	@Bind(id = "module")
	private String module;

	// @Bind(id = "isLay")
	// private String isLay;

	@SaveState
	public CommonKeyType com = null;
	protected ICommonKeyTypeDao dao = SpringBeanHolder.getBean("commonKeyTypeDao");
	protected ICommonKeyService commonKeyService = SpringBeanHolder
			.getBean("commonKeyService");

	@Bind(id = "isLay", attribute = "value")
	@SelectItems(source = "#{this.isLay_items}")
	protected boolean isLay;

	@Accessible
	protected SelectItem[] isLay_items = SelectItemsProvider.getYesNo();

	public void setProperty() {
		if (com == null)
			return;
		if (id != null && !"".equals(id))
			com.setId(id);

		com.setTypeCode(typeCode);
		com.setIsLay(isLay);
		com.setModule(module);
		com.setTypeName(typeName);
	}

	protected void getProperty() {
		if (com == null)
			return;
		id = com.getId();
		typeCode = com.getTypeCode();
		isLay = com.getIsLay();
		module = com.getModule();
		typeName = com.getTypeName();

	}

}
